<?php

	class FileUploadView {
		
		private $uploadButton = "uploadButton";
		
		public function UploadForm() {
			
			return "
				<form action='' method='post' enctype='multipart/form-data' id='uploadForm'>
					<p><input type='file' name='file' id='file' />
					<input type='submit' name='$this->uploadButton' value='Ladda upp' class='button' /></p>
				</form>";
		}
		
		//Skriver ut bilderna till en "slide"
		public function FileList() {
			
			$dir = opendir("files/");			
			$slide = "
				<div id='slideshow'>
					<div id='galleryContainer'>
						<div id='arrowLeft'><img src='images/arrowLeft.png'></div>
						<div id='arrowRight'><img src='images/arrowRight.png'></div>
						<div id='theImages'>";
			
			while (($file = readdir($dir)) !== false) {
				if (($file != ".") && ($file != "..")) {
					$slide .= "<a href='#'><img src='files/$file' widht='133' height='100'></a>";
				}
			}

			closedir($dir);
			
			$slide .= "							
				<div id='slideEnd'></div></div></div></div>";
				
			return $slide;			
		}
		
		public function ErrorMessage() {
			return "
				<div id='errorMessage'>
					<div id='wrongFileDiv'>The file is invalid or already exists.</div>
				</div>";
		}
		
		public function Files() {
			return $_FILES; 
		}
		
		//Kollar knappen.
		public function UploadButton() {
			if (isset($_POST[$this->uploadButton]) == true) {
				return true;
			}		
			return false;
		}
	}
